package com.hcg.initproject.controller;

import com.hcg.initproject.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 异步调用技术
 */
@RestController
@Slf4j
@EnableAsync
public class UserController {
    // 值是在初始化的时候赋予的
    @Value("${http_url}")
    private String http_url;

    @Autowired
    private UserService userService;

//    @Async
    @RequestMapping("/user/msg")
    public String orderAndSendMSG(){
        log.info("1");
        String s = userService.orderAndSendMSG();
        log.info("4");
        return s;
    }
    @RequestMapping("/user/value")
    public String getNameAndAge(){
        return userService.setValue();
    }

    @RequestMapping("/user/url")
    public String readUrl(){
        return http_url;
    }


}
